# Appendix B: Address Space Bit Masks

In a number of Helix Universal Server features, you can identify a range of IP addresses by assigning a bit mask to an IP address. Helix Universal Server interprets the bit mask as a single, contiguous block of address spaces. This appendix describes how to create a bit mask for the purpose of identifying a range of IP addresses.

# Understanding Basic IP Address Construction

To understand how bit masks work, it is helpful to review the basic concepts for constructing an IP address. Each IP address is 32 bits, divided into four 8- bit octets. Each bit in an octet is assigned a value between 128 and 1, from left to right. To indicate whether a value is in use, the bit is set to 1. The sum of all bit values for each octet determines the octet's dotted decimal value. The following defines values for each bit in an octet:

| Bit 1 | Bit 2 | Bit 3 | Bit 4 | Bit 5 | Bit 6 | Bit 7 | Bit 8
Bit Value: | `128` | `64` | `32` | `16` | `8` | `4` | `2` | `1`

It is possible to make any number between 0 and 255 simply by indicating whether each bit in an octet is set to 1 or 0. For example, both of the following expressions indicate the same IP address:

dotted decimal: | `192.0.1.2`
32-bit binary equivalent: | `11000000 00000000 00000001 00000010`

# Using a Bit Mask to Identify an Address Space

To indicate a range of IP addresses, you must first identify the lowest IP address in your range, and then indicate the number of bits that are identical between that address and the highest IP address in the range. Consider the range of IP addresses `192.0.1.255` to `192.0.1.0`.

These two addresses indicate a range of 256 possible address (in practice only 254, because the all-zero and all-one addresses are reserved). Between the two indicated addresses, `192.0.1.0 is` the lowest in the range, and the first three octets (the first 24 bits) are exactly the same for both addresses. Consider the following addresses and the bit mask expressed in binary.

Addresses and Bit Mask
Address and Mask | Dotted Decimal | 32-Bit Binary Equivalent
--- | --- | ---
Highest Address | `192.0.1.255` | `11000000 00000000 00000001 11111111`
Lowest Address | `192.0.1.0` | `11000000 00000000 00000001 00000000`
Bit Mask | `24 Bits` | `11111111 11111111 11111111 00000000`

Notice that the first 24 bits in the highest and lowest addresses are exactly the same. The same would be true if you had used an address with any decimal number (0-255) in the last octet. The bit mask uses 1's to indicate bits to be evaluated, and 0's to indicate bits to be masked. Thus, assigning a bit mask of `255.255.255.0` to the lowest IP address in the range indicates an address space of 256 possible IP addresses.

## Slash Notation

In the preceding table, the bit mask appears in both its dotted decimal and 32- Bit binary form. However, this same address space can also be articulated with slash notation like this:

`192.0.1.0/24`

Slash notation uses the lowest IP address in the range, followed by a slash and a number that indicates how many bits should be evaluated. This is helpful to understand because in Helix Universal Server you indicate a bit mask in a similar manner. You select the number of bits—from 0 bits through 32 bits— from a pull-down list.

## Address Space Size

The size of the address space is determined by the number of bits included in the bit mask. The fewer bits used, the more addresses that are included in the address space. An 8-bit mask includes 224 power addresses, while a 24-bit mask includes only 28 power addresses.

# Bit Boundaries

Bit boundaries also affect which address can be included in an address space. To understand how bit boundaries work, recall that each octet includes 8 bits, and that each bit has an assigned value. Ranges correspond to the value of each bit in an octet. Further, these ranges cannot cross bit boundaries. Consider the following addresses:

Bit Boundary with an Inappropriate Mask
Address and Mask | Dotted Decimal | 32-Bit Binary Equivalent
--- | --- | ---
Highest Address | `192.0.0.2` | `11000000 00000000 00000000 00000010`
Lowest Address | `192.0.0.1` | `11000000 00000000 00000000 00000001`
Bit Mask | `31 Bits` | `11111111 11111111 11111111 11111110`

Although there are only two consecutive addresses in the range shown in the preceding table, you cannot create a range of two with these addresses, because bit 31 is different for each address. This is a bit boundary. To create a range for these addresses, use the sixth bit in the fourth octet, or a bit mask of 30. Note, though, that by using 30 bits, you also end up including more addresses:

Bit Boundary with an Appropriate Mask
Address and Mask | Dotted Decimal | 32-Bit Binary Equivalent
--- | --- | ---
Highest Address | `192.0.1.3` | `11000000 00000000 00000001 00000011`
`192.0.1.2` | `11000000 00000000 00000001 00000010`
`192.0.1.1` | `11000000 00000000 00000001 00000001`
Lowest Address | `192.0.1.0` | `11000000 00000000 00000001 00000000`
Bit Mask | `30 Bits` | `11111111 11111111 11111111 11111100`

## Determining Bit Boundaries

The chart below identifies every literal bit range available. Look up the bit for the octet you are working with in the Bit column on the left. Then use the corresponding Literal Bit Range column to look up the decimal values available for each range.

For example, the problem described above arose from attempting to use bit 7 in the fourth octet (Bit 31). However, in row 7 of the table below, no range includes decimal 1 through 2. For a range that works, you need to use the sixth bit in the fourth octet (Bit `30`). Notice that in row 6, there is a decimal range that includes 1 through 2 (range `0-3`).

Literal Bit Ranges
Bit | Literal Bit Ranges
--- | ---
1 | Ranges of `0-127;` or `128-255`
2 | Ranges of `0-63; 64-127; 128-191;` or `192-255`
3 | Ranges of `0-31; 32-63; 64-95; 96-127; 128-159; 160-191; 192-223; 224-255`
4 | Ranges of `0-15; 16-31; 32-47; 48-63; 64-79; 80-95; 96-111; 112-127; 128-143; 144-159; 160-175; 176-191; 192-207; 208-223; 224-239; 240-255`
5 | Ranges of `0-7; 8-15; 16-23; 24-31; 32-39; 40-47; 48-55; 56-63; 64-71; 72-79; 80-87; 88-95; 96-103; 104-111; 112-119; 120-127; 128-135; 136-143; 144-151; 152-159; 160-167; 168-175; 176-183; 184-191; 192-199; 200-207; 208-215; 216-223; 224-231; 232-239; 240-247; 248-255`
6 | Ranges of `0-3; 4-7; 8-11; 12-15; 16-19; 20-23; 24-27; 28-31; 32-35; 36-39; 40-43; 44-47; 48-51; 52-55; 56-59; 60-63; 64-67; 68-71; 72-75; 76-79; 80-83; 84-87; 88-91; 92-95; 96-99; 100-103; 104-107; 108-111; 112-115; 116-119; 120-123; 124-127; 128-131; 132-135; 136-139; 140-143; 144-147; 148-151; 152-155; 156-159; 160-163; 164-167; 168-171; 172-175; 176-179; 180-183; 184-187; 188-191; 192-195; 196-199; 200-203; 204-207; 208-211; 212-215; 216-219; 220-223; 224-227; 228-231; 232-235; 236-239; 240-243; 244-247; 248-251; 252-255`
7 | Ranges of `0-1; 2-3; 4-5; 6-7; 8-9; 10-11; 12-13; 14-15; 16-17; 18-19; 20-21; 22-23; 24-25; 26-27; 28-29; 30-31; 32-33; 34-35; 36-37; 38-39; 40-41; 42-43; 44-45; 46-47; 48-49; 50-51; 52-53; 54-55; 56-57; 58-59; 60-61; 62-63; 64-65; 66-67; 68-69; 70-71; 72-73; 74-75; 76-77; 78-79; 80-81; 82-83; 84-85; 86-87; 88-89; 90-91; 92-93; 94-95; 96- 97; 98-99; 100-101; 102-103; 104-105; 106-107; 108-109; 110-111; 112-113; 114-115; 116-117; 118-119; 120-121; 122-123; 124-125; 126-127; 128-129; 130-131; 132-133; 134-135; 136-137; 138-139; 140-141; 142-143; 144-145; 146-147; 148-149; 150-151; 152-153; 154-155; 156-157; 158-159; 160-161; 162-163; 164-165; 166-167; 168-169; 170-171; 172-173; 174-175; 176-177; 178-179; 180-181; 182-183; 184-185; 186-187; 188-189; 190-191; 192-193; 194-195; 196-197; 198-199 200-201; 202-203; 204-205; 206-207; 208-209; 210-211; 212-213; 214-215; 216-217; 218-219; 220-221; 222-223; 224-225; 226-227; 228-229; 230-231; 232-233; 234-235; 236-237; 238-239; 240-241; 242-243; 244-245; 246-247; 248-249; 250-251; 252-253; 254-255`
8 | Only an exact match is possible.

# Working with 0-Bit and 32-Bit Masks

There are two masks that create somewhat special cases: 0-Bits and 32-Bits. When an IP address has a 32-Bit mask, it creates a literal range of 1. For example, consider the following address and 32-Bit mask:

`192.0.1.1 /32`

When Helix Universal Server evaluates incoming IP addresses against this IP address, there is only one possible match: `192.0.1.1`. For a match, the incoming address must match all 32-Bits in the original address.

Just as there is only one possible match for addresses with a 32-Bit mask, the opposite is true for addresses with a 0-Bit mask. An IP address with a 0-bit mask essentially tells Helix Universal Server to match any addresses. Although not required, you should also enter an origin address of all zeros, like so:

`0.0.0.0 /0`

This works because Helix Universal Server uses a Boolean and operation to evaluate incoming addresses. In this type of algorithm, anything and zero equals zero, so all incoming addresses end up equal to the all-zero address entered as the origin address.

| © 2002 RealNetworks, Inc. All rights reserved. For more information, visit RealNetworks Click here if the Table of Contents frame is not visible at the left side of your screen.